package com.mrjy.live.bo;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.mrjy.common.entity.WisSign;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.util.CharSetUtil;
import com.mrjy.common.util.DateUtil;
import com.mrjy.live.dao.IWisSignDao;

@Service("wisSignBo")
public class WisSignBo implements IWisSignBo {
	@Resource
	private IWisSignDao wisSignDao;



	@Override
	public Map<String, Object> queryPageWisSign(WisSign wisSign,UserInfo userInfo) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("total", wisSignDao.countWisSign(wisSign));
		List<WisSign> list = wisSignDao.queryPageWisSign(wisSign);	
		map.put("rows",list);
		return map;
	}

	@Override
	public int insert(WisSign wisSign) {
		// TODO Auto-generated method stub
		//wisSign.setUserName(CharSetUtil.toUTF8(wisSign.getUserName()));
		wisSign.setRegisterTime(DateUtil.dateToString(new Date(), 2));
		wisSign.setDisableFlag(0);
		return wisSignDao.insert(wisSign);
	}

	@Override
	public WisSign queryById(int id) {
		// TODO Auto-generated method stub
		return wisSignDao.queryById(id);
	}

	@Override
	public int updateById(WisSign wisSign) {
		// TODO Auto-generated method stub
		return wisSignDao.updateById(wisSign);
	}

	@Override
	public int deleteByIds(int[] ids) {
		// TODO Auto-generated method stub
		try{
			return wisSignDao.deleteByIds(ids);
		}catch(DataAccessException  e){
			return 0;
		}
	}

	@Override
	public int updateDisableFlag(WisSign wisSign) {
		// TODO Auto-generated method stub
		return wisSignDao.updateDisableFlag(wisSign);
	}

}
